﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Chaliy.DbPro.Generators.TextAuthoring;
using Chaliy.DbPro.Generators.TextAuthoring.Configuration;

namespace Chaliy.DbPro.Generators.Tests.TextAuthoring
{
	[TestClass]
	public class TermSelectorTests
	{
		[TestMethod]
		[DeploymentItem(DeploymentConstants.GeneratorsDll)]
		public void TestGetNextTerm()
		{
			ITermAccessor accessor = TermSelectorTests.CreateEtalonTermAccessor();
			TermSelector selector = new TermSelector(accessor);
			string result = selector.GetNextTerm();

			TermAccessorUtilities.AssertStringExistsWithinAccessor(result, accessor);
		}

		[TestMethod]
		[DeploymentItem(DeploymentConstants.GeneratorsDll)]
		[ExpectedException(typeof(ArgumentNullException))]
		public void TestConstructorEmptyArgument()
		{
			// Exception expected here because 
			// TermSelector cannot work without accessor
			new TermSelector(null);
		}		

		private static ITermAccessor CreateEtalonTermAccessor()
		{
			return new ListTermAccessor(
				new List<TermConfiguration>
				{
					new TermConfiguration{Value = "Rob", Weight = 0.8},
					new TermConfiguration{Value = "Bob", Weight = 0.1},
					new TermConfiguration{Value = "Dob", Weight = 0.1}
				}
			);
		}
	}
}
